package c.e.a.a.f.n;

import android.content.Context;
import java.util.HashMap;
import java.util.Map;

/* compiled from: MetadataBackendRegistry */
public class k implements e {
    public final a a;
    public final i b;
    public final Map<String, m> c = new HashMap();

    /* compiled from: MetadataBackendRegistry */
    public static class a {
        public final Context a;
        public Map<String, String> b = null;

        public a(Context context) {
            this.a = context;
        }

        /* JADX WARNING: Removed duplicated region for block: B:16:0x0044  */
        /* JADX WARNING: Removed duplicated region for block: B:15:0x003a  */
        public c.e.a.a.f.n.d a(java.lang.String r15) {
            /*
            r14 = this;
            r0 = "Could not instantiate %s";
            r1 = "Could not instantiate %s.";
            r2 = r14.b;
            r3 = 0;
            r4 = "BackendRegistry";
            r5 = 0;
            if (r2 != 0) goto L_0x0096;
        L_0x000c:
            r2 = r14.a;
            r6 = r2.getPackageManager();	 Catch:{ NameNotFoundException -> 0x0032 }
            if (r6 != 0) goto L_0x001a;
        L_0x0014:
            r2 = "Context has no PackageManager.";
            android.util.Log.w(r4, r2);	 Catch:{ NameNotFoundException -> 0x0032 }
            goto L_0x0037;
        L_0x001a:
            r7 = new android.content.ComponentName;	 Catch:{ NameNotFoundException -> 0x0032 }
            r8 = com.google.android.datatransport.runtime.backends.TransportBackendDiscovery.class;
            r7.<init>(r2, r8);	 Catch:{ NameNotFoundException -> 0x0032 }
            r2 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
            r2 = r6.getServiceInfo(r7, r2);	 Catch:{ NameNotFoundException -> 0x0032 }
            if (r2 != 0) goto L_0x002f;
        L_0x0029:
            r2 = "TransportBackendDiscovery has no service info.";
            android.util.Log.w(r4, r2);	 Catch:{ NameNotFoundException -> 0x0032 }
            goto L_0x0037;
        L_0x002f:
            r2 = r2.metaData;	 Catch:{ NameNotFoundException -> 0x0032 }
            goto L_0x0038;
        L_0x0032:
            r2 = "Application info not found.";
            android.util.Log.w(r4, r2);
        L_0x0037:
            r2 = r3;
        L_0x0038:
            if (r2 != 0) goto L_0x0044;
        L_0x003a:
            r2 = "Could not retrieve metadata, returning empty list of transport backends.";
            android.util.Log.w(r4, r2);
            r2 = java.util.Collections.emptyMap();
            goto L_0x0094;
        L_0x0044:
            r6 = new java.util.HashMap;
            r6.<init>();
            r7 = r2.keySet();
            r7 = r7.iterator();
        L_0x0051:
            r8 = r7.hasNext();
            if (r8 == 0) goto L_0x0093;
        L_0x0057:
            r8 = r7.next();
            r8 = (java.lang.String) r8;
            r9 = r2.get(r8);
            r10 = r9 instanceof java.lang.String;
            if (r10 == 0) goto L_0x0051;
        L_0x0065:
            r10 = "backend:";
            r10 = r8.startsWith(r10);
            if (r10 == 0) goto L_0x0051;
        L_0x006d:
            r9 = (java.lang.String) r9;
            r10 = -1;
            r11 = ",";
            r9 = r9.split(r11, r10);
            r10 = r9.length;
            r11 = 0;
        L_0x0078:
            if (r11 >= r10) goto L_0x0051;
        L_0x007a:
            r12 = r9[r11];
            r12 = r12.trim();
            r13 = r12.isEmpty();
            if (r13 == 0) goto L_0x0087;
        L_0x0086:
            goto L_0x0090;
        L_0x0087:
            r13 = 8;
            r13 = r8.substring(r13);
            r6.put(r12, r13);
        L_0x0090:
            r11 = r11 + 1;
            goto L_0x0078;
        L_0x0093:
            r2 = r6;
        L_0x0094:
            r14.b = r2;
        L_0x0096:
            r2 = r14.b;
            r15 = r2.get(r15);
            r15 = (java.lang.String) r15;
            if (r15 != 0) goto L_0x00a1;
        L_0x00a0:
            return r3;
        L_0x00a1:
            r2 = 1;
            r6 = java.lang.Class.forName(r15);	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r7 = c.e.a.a.f.n.d.class;
            r6 = r6.asSubclass(r7);	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r7 = new java.lang.Class[r5];	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r6 = r6.getDeclaredConstructor(r7);	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r7 = new java.lang.Object[r5];	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r6 = r6.newInstance(r7);	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            r6 = (c.e.a.a.f.n.d) r6;	 Catch:{ ClassNotFoundException -> 0x00ef, IllegalAccessException -> 0x00e2, InstantiationException -> 0x00d5, NoSuchMethodException -> 0x00c8, InvocationTargetException -> 0x00bb }
            return r6;
        L_0x00bb:
            r1 = move-exception;
            r2 = new java.lang.Object[r2];
            r2[r5] = r15;
            r15 = java.lang.String.format(r0, r2);
            android.util.Log.w(r4, r15, r1);
            goto L_0x00fd;
        L_0x00c8:
            r1 = move-exception;
            r2 = new java.lang.Object[r2];
            r2[r5] = r15;
            r15 = java.lang.String.format(r0, r2);
            android.util.Log.w(r4, r15, r1);
            goto L_0x00fd;
        L_0x00d5:
            r0 = move-exception;
            r2 = new java.lang.Object[r2];
            r2[r5] = r15;
            r15 = java.lang.String.format(r1, r2);
            android.util.Log.w(r4, r15, r0);
            goto L_0x00fd;
        L_0x00e2:
            r0 = move-exception;
            r2 = new java.lang.Object[r2];
            r2[r5] = r15;
            r15 = java.lang.String.format(r1, r2);
            android.util.Log.w(r4, r15, r0);
            goto L_0x00fd;
        L_0x00ef:
            r0 = move-exception;
            r1 = new java.lang.Object[r2];
            r1[r5] = r15;
            r15 = "Class %s is not found.";
            r15 = java.lang.String.format(r15, r1);
            android.util.Log.w(r4, r15, r0);
        L_0x00fd:
            return r3;
            */
            throw new UnsupportedOperationException("Method not decompiled: c.e.a.a.f.n.k$a.a(java.lang.String):c.e.a.a.f.n.d");
        }
    }

    public k(Context context, i iVar) {
        a aVar = new a(context);
        this.a = aVar;
        this.b = iVar;
    }

    public synchronized m a(String str) {
        if (this.c.containsKey(str)) {
            return (m) this.c.get(str);
        }
        d a = this.a.a(str);
        if (a == null) {
            return null;
        }
        i iVar = this.b;
        m create = a.create(new c(iVar.a, iVar.b, iVar.c, str));
        this.c.put(str, create);
        return create;
    }
}
